<?php

/**
 * ordenesservicio form.
 *
 * @package    gescell
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfPropelFormTemplate.php 10377 2008-07-21 07:10:32Z dwhittle $
 */
class ordenesservicioForm extends BaseordenesservicioForm
{
  public function configure()
  {
      //$this->widgetSchema['sf_guard_user'] = new sfWidgetFormInput();
      $this->widgetSchema['clientes_id'] = new sfWidgetFormChoice(array(
         'choices'          => array(),
         'renderer_class'   => 'sfWidgetFormPropelJQueryAutocompleter',
         'renderer_options' => array(
         'model'            => 'clientes',
         'url'              => $this->getOption('url'),
    )
    ));
    $this->widgetSchema['clientes_id']->setattribute('size', '50');
    $this->widgetSchema['sf_guard_user']->setattribute('class', 'select ui-widget-content ui-corner-all');
    $this->widgetSchema['sf_guard_user']->setattribute('type', 'text');
    $this->widgetSchema['fechaingreso']  = new sfWidgetFormJQueryDate(array(
          'format' =>  '%day%/%month%/%year%'
      ));


   // $modelosxingresos = $this->getObject()->getmodelosxingresoss();
   /* //if(!$modelosxingresos){
        $modelosxingresos = new modelosxingresos();
        $modelosxingresos->setordenesservicio($this->getObject());
        $modelosxingresos->setEstadosdereparacionId(1);
        $detallemodelos = array($modelosxingresos);
   // }
     $detalles_forms = new sfForm();
     $count = 0;
     foreach ($detallemodelos as $detalle) {
            $detall_form = new modelosxingresosForm($detalle);
            $detalles_forms->embedForm($count, $detall_form);
            $count ++;
        }
        $this->embedForm('detalles', $detalles_forms);
  }
  //Agregado para Pruebas de Creacion dinamica de Campos para el embebido
   public function adddetallesEmbebidos($num){
         $det = new modelosxingresos();
         $det->setordenesservicio($this->getObject());
         $det_form = new modelosxingresosForm($det);
        //Empotramos la nueva p�cture en el contenedor
         $this->embeddedForms['detalles']->embedForm($num, $det_form);
        //Volvemos a empotrar el contenedor
        $this->embedForm('detalles', $this->embeddedForms['detalles']);
    }




   public function bind(array $taintedValues = null, array $taintedFiles = null)
    {
      foreach($taintedValues['detalles'] as $key=>$nuevoDetalle)
      {
        if (!isset($this['detalles'][$key]))
        {
          $this->adddetallesEmbebidos($key);
        }
      }
      parent::bind($taintedValues, $taintedFiles);
*/}

}
